import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { REQUEST_USER_KEY } from '../constants';
import { GlobalAPI } from '../typings/global';

export const Payload = createParamDecorator((data, ctx: ExecutionContext) => {
  const request: Request = ctx.switchToHttp().getRequest();
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
  return request[REQUEST_USER_KEY] as GlobalAPI.PayloadProps;
});
